<%--
  Created by IntelliJ IDEA.
  User: Rain
  Date: 2018/5/14
  Time: 14:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<html>
<head>
    <title>报价方案</title>
    <jsp:include page="../../import.jsp" flush="true"/>
</head>
<body>
<body class="iframeBody">
<div class="Wrapper">
    <div class="fieldset1 tabel_col tabel_col_s clearFix">
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>报价版</span>
            </div>
            <div class="sqPanel_body">
                <div class="fieldBox col_33">
                    <div class="label">保费金额(元)</div>
                    <div class="field">
                    	<span id="insAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">期数</div>
                    <div class="field">
                          <span id="payPd"></span>
                        <span id="spanPayPd"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">月平息(%)</div>
                    <div class="field">
                      <span id="avgMonInterest"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">首期租金比例(%)</div>
                    <div class="field">
                     <span id="firstRentalPct"></span>
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">首期租金(元)</div>
                    <div class="field">
                    	<span id="firstRental"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">年平息(%)</div>
                    <div class="field">
                    	<span id="annualAvgInterest"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">咨询费比例(%)</div>
                    <div class="field">
                    	<span id="consultingFeePct"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">咨询费(元)</div>
                    <div class="field">
                    	<span id="consultingFeeAmt"></span>
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">年利率(%)</div>
                    <div class="field">
                    	<span id="annualRate"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">保证金比例(%)</div>
                    <div class="field">
                    	<span id="depositPct"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">保证金金额(元)</div>
                    <div class="field">
                    	<span id="depositAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">留购价(元)</div>
                    <div class="field">
                    <span id="purchasePriceAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">首期款合计(元)</div>
                    <div class="field">
                    	<span id="firstAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="field"></div>
                    <div class="field">

                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="field"></div>
                    <div class="field">

                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">调整比例(%)</div>
                    <div class="field">
                    	<span id="adjustPct"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">融资额(元)</div>
                    <div class="field">
                        <span id="financingAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">IRR(%)</div>
                    <div class="field">
                    <span id="IRR"></span>
                    </div>
                </div>
            </div>
        </div>

    </div>
    <div class="clearFix"></div>
    <!-- <div class="btnsBox formBtns notRight">
        <span id="calcBtn" onclick="calcBtn();" class="sq-button sq-button-round">测算</span>
    </div> -->
    <div class="fieldset1 tabel_col tabel_col_s clearFix">
        <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>录入版</span>
            </div>
            <div class="sqPanel_body">
                <div class="fieldBox col_33">
                    <div class="label">保费金额（元）</div>
                    <div class="field">
                        <span id="logInsAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">期数</div>
                    <div class="field">
                        <span id="logPayPd"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">月平息（%）</div>
                    <div class="field">
                        <span id="logAvgMonInterest"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">首期租金比例（%）</div>
                    <div class="field">
                        <span id="logFirstRentalPct"></span>
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">首期租金（元）</div>
                    <div class="field">
                        <span id="logFirstRental"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">年平息（%）</div>
                    <div class="field">
                        <span id="logAnnualAvgInterest"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">咨询费比例（%）</div>
                    <div class="field">
                        <span id="logConsultingFeePct"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">咨询费（元）</div>
                    <div class="field">
                        <span id="logConsultingFeeAmt"></span>
                    </div>
                </div>

                <div class="fieldBox col_33">
                    <div class="label">年利率（%）</div>
                    <div class="field">
                        <span id="logAnnualRate"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">保证金比例（%）</div>
                    <div class="field">
                        <span id="logDepositPct"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">保证金金额（元）</div>
                    <div class="field">
                        <span id="logDepositAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">留购价（元）</div>
                    <div class="field">
                        <span id="logPurchasePriceAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">首期款合计（元）</div>
                    <div class="field">
                        <span id="logFirstAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">融资额（元）</div>
                    <div class="field">
                        <span id="logFinancingAmt"></span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">IRR（%）</div>
                    <div class="field">
                        <span id="logIRR"></span>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <div id="payDetailGrid" class="sq-grid">
    </div>
</div>
</div>
<input type="hidden" id ="applyId" value="${applicationId }">
</body>
</html>
<script type="application/javascript">
var _applyId = $("#applyId").val();
    var grid = null;
    $(function () {
        initForm();
        initGrid();//注意初始化要在initForm之后,因为在初始化grid的时候需要form参数
        $('#startBtn').attr("disabled", "disabled");  // 禁用
        pricingVersion();
    });

    //初始化表单
    function initForm() {
        $("#searchBar").ligerForm();
    }

    function initGrid() {
    	var _id = $("#applyId").val();
        grid = $("#payDetailGrid").ligerGrid({
            url: '<%=path%>/ins/pay/getPayDetail.do?id='+_id,
            method: 'get',
            columns: [
                {display: '期次', name: 'payPd', minWidth: 50, align: 'center'},
                {display: '还款日期', name: 'repaymentDtNm', minWidth: 150, align: 'center'},
                {display: '租金（元）', name: 'rentAmtNm', minWidth: 100, align: 'center'},
                {display: '本金（元）', name: 'principalAmtNm', minWidth: 100, align: 'center'},
                {display: '利息（元）', name: 'interestAmtNm', minWidth: 40, align: 'center'},
                {display: '剩余应还合计', name: 'remainRepayTotalAmtNm', minWidth: 40, align: 'center'}
            ],
            usePager: false,
            pageSize: 10,
            root: 'rows',
            record: 'total',
            hideLoadButton: true,
            width: '100%',
            checkbox: false,
            rownumbers: true,
            allowUnSelectRow: true,
            alternatingRow: true,
            onSelectRow: function (rowdata, rowNum, rowEl) {
                $.extend(true, pageInApp, {seletedCompRow: rowdata});
            },
            onUnSelectRow: function (rowdata) {
                $.extend(true, pageInApp, {seletedCompRow: null});
            }
        });
    }
    function   pricingVersion(){
    	$.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/inscare/insapplication/getgetQuotation.do',
            data: {"applicationId":_applyId},
            success: function (msg) {
                var data =msg.data;
                if(data != null){
                	 //保费金额
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#insAmt").text(data.insQuoteComputeVO.insAmtNm + " 元");
                    }
                    //期次
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#payPd").text(data.insQuoteComputeVO.payPd + " 期");
                    }
                    //月平息
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#avgMonInterest").text(data.insQuoteComputeVO.avgMonInterest + "%");
                    }
                    //首期租金比例
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#firstRentalPct").text(data.insQuoteComputeVO.firstRentalPct + "%");
                    }
                    //首期租金
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#firstRental").text(data.insQuoteComputeVO.firstRentAmtNm + " 元");
                    }
                    //年平息
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#annualAvgInterest").text(data.insQuoteComputeVO.annualAvgInterest + "%");
                    }
                    //咨询费比例
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#consultingFeePct").text(data.insQuoteComputeVO.consultingFeePct + "%");
                    }
                    //咨询费
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#consultingFeeAmt").text(data.insQuoteComputeVO.consultingFeeAmtNm + " 元");
                    }
                    //年利率
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#annualRate").text(data.insQuoteComputeVO.annualRate + "%");
                    }
                    //保证金比例
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#depositPct").text(data.insQuoteComputeVO.depositPct + "%");
                    }
                    //保证金金额
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#depositAmt").text(data.insQuoteComputeVO.depositAmtNm + " 元");
                    }
                    //留购价
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#purchasePriceAmt").text(data.insQuoteComputeVO.purchasePriceNm + " 元");
                    }
                    //首期款合计
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#firstAmt").text(data.insQuoteComputeVO.firstAmtNm + " 元");
                    }
                    //调整比例
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#adjustPct").text(data.insQuoteComputeVO.adjustPct + "%");
                    }
                    //融资额
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#financingAmt").text(data.insQuoteComputeVO.financingAmtNm + " 元");
                    }
                    //irr
                    if (StringUtils.isNotEmpty(data.insQuoteComputeVO)) {
                        $("#IRR").text(data.insQuoteComputeVO.irrPct + " %");
                    }
                }
                //如果报价版有数据再获取录入版
                inputVersion();
                    return;
                },error:function(msg){
                	$.ligerDialog.SQalert({content: "报价版数据获取失败", SQ_type: "error"});
                }
        });
    }
    
    function   inputVersion(){
    	$.ajax({
            type: 'get',
            dataType: 'json',
            url: '<%=path%>/inscare/insapplication/getgetQuotation.do',
            data: {"applicationId":_applyId},
            success: function (msg) {
                var data =msg.data;
                if(data != null){
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logInsAmt').text(data.insLogComputeVO.insAmtNm + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logPayPd').text(data.insLogComputeVO.payPd + " 期");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logAvgMonInterest').text(data.insLogComputeVO.avgMonInterest + "%");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logFirstRentalPct').text(data.insLogComputeVO.firstRentalPct + "%");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logFirstRental').text(data.insLogComputeVO.firstRentAmtNm + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logAnnualAvgInterest').text(data.insLogComputeVO.annualAvgInterest + "%");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logConsultingFeePct').text(data.insLogComputeVO.consultingFeePct + "%");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logConsultingFeeAmt').text(data.insLogComputeVO.consultingFeeAmtNm + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logAnnualRate').text(data.insLogComputeVO.annualRate + "%");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logDepositPct').text(data.insLogComputeVO.depositPct + "%");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logDepositAmt').text(data.insLogComputeVO.depositAmtNm + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logPurchasePriceAmt').text(data.insLogComputeVO.purchasePriceNm + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logFirstAmt').text(data.insLogComputeVO.firstAmtToltal + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logFinancingAmt').text(data.insLogComputeVO.financingAmtNm + " 元");
                    }
                    if (StringUtils.isNotEmpty(data.insLogComputeVO)) {
                        $('#logIRR').text(data.insLogComputeVO.irrPct + "%");
                    }
                }
                    return;
                },error:function(msg){
                $.ligerDialog.SQalert({content: "录入版数据获取失败", SQ_type: "error"});
                }
        });
    }
</script> 